﻿(function () {
    // var root = document.location.toString().match(/file:\/\//) ? root : document.location.protocol + "//" + document.location.host;
    // var r = new RegExp("(^|(.*?\\/))(index\.js)(\\?|$)"),
    //     s = document.getElementsByTagName('script'), targetScript;
    // for (var i = 0; i < s.length; i++) {
    //     var src = s[i].getAttribute('src');
    //     if (src) {
    //         var m = src.match(r);
    //         if(src.indexOf("index.js")>=0){
    //             var pos = src.indexOf("/index\.js");
    //             //获取引用地址IP
    //             root = src.substring(0, pos);
    //         }
    //         if (m) {
    //             targetScript = s[i];
    //             break;
    //         }
    //     }
    // }
    function inputScript(url) {
        var script = '<script type="text/javascript" src="' + url + '"><' + '/script>';
        document.writeln(script);
    }
    function inputCSS(url) {
        var css = '<link rel="stylesheet" href="' + url + '">';
        document.writeln(css);
    }
    function inArray(arr, item) {
        for (i in arr) {
            if (arr[i] == item) {
                return true;
            }
        }
        return false;
    }
    
    // var root ="http://183.6.188.66:2006";
    var root="./static/webGis/"
    //加载类库资源文件
    function load() {
        // var includes = (targetScript.getAttribute('include') || "").split(",");
        // var excludes = (targetScript.getAttribute('exclude') || "").split(",");
        
        //css引用
        // inputCSS(root +"/libs/webgis.css");
        inputCSS(root+"webgis.css");

        //js引用
        // inputScript(root +"/libs/mapbox-gl.js");
        // inputScript(root +"/libs/webgis_svg.js");
        // inputScript(root +"/libs/webgis.js");

        
        inputScript(root+"mapbox-gl.js");
        inputScript(root+"webgis_svg.js");
        inputScript(root+"webgis.js");

     
        //地图样式引用
        // var styleurl = root +"/assets/style/style.js"
        var styleurl = root +"style.js"
        inputScript(styleurl);

        //配抢
        //var styleurl_pq = root +"/assets/style/style_pq.js"
        //inputScript(styleurl_pq);

        //地图样式wms
        // var wmsStyle = root + "/assets/style/wmsStyle.js"
        var wmsStyle = root+"wmsStyle.js"
        inputScript(wmsStyle);
    }
    load();
    window.serverHost = "http://172.16.0.58:8037";
    window.webgis_base_path ="http://172.16.0.58:8091/";
    window.httpMode="rest";
    window.isLocal = false;
    
    window.grmServers = [
        {"key":"majorNetworkServer","description":"主网空间信息服务"},
        {"key":"distributionNetworkServer","description":"配网空间信息服务"},
        {"key":"api","description":"空间信息服务"}
    ];

    //编辑器服务器地址
    window.editorServer = "http://10.92.13.186:8080";
})();